﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="address.ascx.cs" Inherits="eDream.admin.address" %>
<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<div style="margin-top: 20px">
    <dx:ASPxGridView ID="grvThanhpho" runat="server" Width="600px" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" KeyFieldName="ID" Theme="DevEx">
        <Columns>
            <dx:GridViewCommandColumn VisibleIndex="0">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn Caption="STT" FieldName="ID" ReadOnly="True" VisibleIndex="1" Width="50px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Tên Thành Phố / Tỉnh" FieldName="name" VisibleIndex="2" Width="450px">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsPager Mode="ShowAllRecords"></SettingsPager>
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:reselleradmin_thvConnectionString %>" DeleteCommand="DELETE FROM [Thanhpho] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Thanhpho] ([name]) VALUES (@name)" SelectCommand="SELECT * FROM [Thanhpho]" UpdateCommand="UPDATE [Thanhpho] SET [name] = @name WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
     <div class="Clear"></div>
    <br />
     <div style="margin-bottom: 5px; width: 270px;">
         <dx:ASPxComboBox ID="cbThanhpho" runat="server" Width="200px" DataSourceID="SqlDataSource1" Theme="DevEx" ValueField="ID" TextField="name" AutoPostBack="true"></dx:ASPxComboBox>

    </div>
    
    <div class="Clear"></div>
    <dx:ASPxGridView ID="grvQuanhuyen" runat="server" AutoGenerateColumns="False" Width="600px" DataSourceID="SqlDataSource2" KeyFieldName="ID" Theme="DevEx">
        <Columns>
            <dx:GridViewCommandColumn VisibleIndex="0">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
                <DeleteButton Visible="True">
                </DeleteButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn Caption="STT" FieldName="ID" ReadOnly="True" VisibleIndex="1" Width="50px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Tên Quận/Huyện" FieldName="name" VisibleIndex="2" Width="200px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Tỉnh/ Thành" FieldName="idTP" VisibleIndex="3" Width="200px">
                <PropertiesComboBox DataSourceID="SqlDataSource1" ValueField="ID" TextField="name"></PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
        </Columns>
        <Settings ShowFilterRow="True" />
        <SettingsPager Mode="ShowAllRecords"></SettingsPager>
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:reselleradmin_thvConnectionString %>" DeleteCommand="DELETE FROM [Quan_huyen] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Quan_huyen] ([name], [idTP]) VALUES (@name, @idTP)" SelectCommand="SELECT * FROM [Quan_huyen] WHERE ([idTP] = @idTP)" UpdateCommand="UPDATE [Quan_huyen] SET [name] = @name, [idTP] = @idTP WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="idTP" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="cbThanhpho" Name="idTP" PropertyName="Value" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="idTP" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <div class="Clear"></div>
    <div style="margin-bottom: 5px;margin-top:10px; width: 270px;">
         <dx:ASPxComboBox ID="cbQuan" runat="server" Width="200px" Theme="DevEx" ValueField="ID" TextField="name" AutoPostBack="True" DataSourceID="SqlDataSource2" ></dx:ASPxComboBox>
    </div>
    <dx:ASPxGridView ID="grvPhuongxa" runat="server" Width="600px" Theme="DevEx" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" KeyFieldName="ID">
        <Columns>
            <dx:GridViewCommandColumn VisibleIndex="0">
                <EditButton Visible="True">
                </EditButton>
                <NewButton Visible="True">
                </NewButton>
                <DeleteButton Visible="True">
                </DeleteButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn Caption="STT" FieldName="ID" ReadOnly="True" VisibleIndex="1">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Phường/ Xã" FieldName="name" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Quận/ huyện" FieldName="idquan" VisibleIndex="3">
                <PropertiesComboBox DataSourceID="SqlDataSource4" ValueField="ID" TextField="name"></PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
        </Columns>
        <SettingsPager Mode="ShowAllRecords"></SettingsPager>
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:reselleradmin_thvConnectionString %>" DeleteCommand="DELETE FROM [phuong_xa] WHERE [ID] = @ID" InsertCommand="INSERT INTO [phuong_xa] ([name], [idquan]) VALUES (@name, @idquan)" SelectCommand="SELECT * FROM [phuong_xa] WHERE ([idquan] = @idquan)" UpdateCommand="UPDATE [phuong_xa] SET [name] = @name, [idquan] = @idquan WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="idquan" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="cbQuan" Name="idquan" PropertyName="Value" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="idquan" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <br />
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:reselleradmin_thvConnectionString %>" SelectCommand="SELECT * FROM [Quan_huyen] WHERE ([ID] = @ID)">
        <SelectParameters>
            <asp:ControlParameter ControlID="cbQuan" Name="ID" PropertyName="Value" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</div>